<?php

namespace front\models;

use Yii;

/**
 * This is the model class for table "region".
 *
 * @property integer $id
 * @property string $name
 * @property integer $parent_id
 * @property string $short_name
 * @property integer $level
 * @property string $city_code
 * @property string $zip_code
 * @property string $merger_name
 * @property double $lng
 * @property double $lat
 * @property string $pinyin
 */
class RegionModel extends \common\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'region';
    }

    /**
     * @return \yii\db\Connection the database connection used by this AR class.
//     */
    public static function getDb()
    {
        return Yii::$app->get('db');
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'name', 'short_name', 'merger_name', 'pinyin'], 'required'],
            [['id', 'parent_id', 'level'], 'integer'],
            [['lng', 'lat'], 'number'],
            [['name', 'short_name', 'pinyin'], 'string', 'max' => 45],
            [['city_code'], 'string', 'max' => 4],
            [['zip_code'], 'string', 'max' => 6],
            [['merger_name'], 'string', 'max' => 100]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'parent_id' => 'Parent ID',
            'short_name' => 'Short Name',
            'level' => 'Level',
            'city_code' => 'City Code',
            'zip_code' => 'Zip Code',
            'merger_name' => 'Merger Name',
            'lng' => 'Lng',
            'lat' => 'Lat',
            'pinyin' => 'Pinyin',
        ];
    }
}
